package lt.mii.optimum;

import java.util.Iterator;

import lt.mii.optimum.components.Student;
import lt.mii.optimum.components.Subject;
import lt.mii.optimum.components.Teacher;
import lt.mii.optimum.components.Week;
import lt.mii.optimum.data.Data;
import lt.mii.optimum.io.XmlFileOut;

/**
 * Class used to start the creation of schedule.<br>
 * Reads All initial data from data file.<br>
 * Creates a new {@link Week} object.
 * 
 * @author dstrukov
 * 
 */
public class Start {

	public static final Data data = new Data();



	/**
	 * Program entry point.
	 * 
	 * @param args
	 * 
	 */

	public static void main(String[] args) {
		new Start();
	}



	/**
	 * Constructor <br>
	 * Contains hardcoded path to initial data file. Later shall be replaced by
	 * file upload or dinamic file selection.
	 * 
	 */
	public Start() {


		new Week();

		System.out.println("done");
		outputS();
		outputT();
		outputSub();
		
	}



	/**
	 * Performs Data input from provided XML file
	 * 
	 * @param path
	 *            Full Path to Initial Data file
	 */

	/**
	 * Method used for for testing only. <br>
	 * Outputs all Student data into c:/aStud.xml file
	 */
	public void outputS() {

		XmlFileOut out = new XmlFileOut("aStud.xml", "c:/");

		Iterator<Student> it = data.getStudents().iterator();
		while (it.hasNext()) {
			Student stud = it.next();
			out.startRow();
			out.addTag(stud.toString());
			out.endRow();

		}

		out.close();

	}



	/**
	 * Method used for for testing only. <br>
	 * Outputs all Subject data into c:/aSub.xml file
	 */
	public void outputSub() {

		XmlFileOut out = new XmlFileOut("aSub.xml", "c:/");

		Iterator<Subject> it = data.getSubjects().iterator();
		while (it.hasNext()) {
			Subject stud = it.next();
			out.startRow();
			out.addTag(stud.toString());
			out.endRow();
		}

		out.close();

	}



	/**
	 * Method used for for testing only. <br>
	 * Outputs all Teacher data into c:/aTeach.xml file
	 */
	public void outputT() {

		XmlFileOut out = new XmlFileOut("aTeach.xml", "c:/");

		Iterator<Teacher> tit = data.getTeachers().iterator();
		while (tit.hasNext()) {
			Teacher stud = tit.next();
			out.startRow();
			out.addTag(stud.toString());
			out.endRow();

		}

		out.close();

	}

}
